Create your own plugin
- Fork this repository
- Create a folder to
plugins/community
in your fork. Use dashes to seperate words when naming this folder. - In the folder you created, add a file
index.ts
- Create a function within
index.ts
to that takes in the RequestReceiving requestsNOTE: The way Fleeting Notes sends requests is subject to change. This document will be updated accordingly. The Request object is an object from the Deno fetch library. When a slash command is called from a note, the note and some metadata will be sent to your function. In order to access this data, you'll need to convert the body into a JSON object. See how to do so below: var json = await request.json(); var metadata = json['metadata']; var note = json['note']; as a parameter and returns a ResponseSending responsesNOTE: The way Fleeting Notes handles responses is subject to change. This document will be updated accordingly. The Response object is an object from the Deno fetch library. If status code is 200: * AND response contains a note object, then the current note is updated to match the note object. var exampleNote = { "note": { "title": "new title", "content": "new content", "source": "new source", } } return new Response(JSON.stringify(exampleNote)); * AND response does not contain a no. For example:
export default (request: Request) : Response => {
var exampleNote = {
"note": {
"title": "new title"
"content": "new content",
"source": "new source",
}
}
return new Response(JSON.stringify(exampleNote));
}
- Test your plugin locallyTest your plugin locally1. Install deno 1. Within the folder you created for your plugin, create a file called webserver.ts and add the following lines to it. import { serve } from "https://deno.land/[email protected]/http/server.ts"; import myPlugin from "./index.ts" serve(myPlugin); 2. Now run the deno command to start the webserver deno run --allow-all webserver.ts 3. Once the webserver is up and running go to http://localhost:8000 to call the function you created in index.ts 3. Here is an example curl request to get to ensure it works as expected
- Create a pull request from your fork to the main repostory
See plugins/community/example for an up-to-date example.